package com.example.demo.controller;

import com.example.demo.entity.PurchaseApplyOrder;
import com.example.demo.entity.TvInfo;
import com.example.demo.service.TvInfoService;
import com.example.demo.util.GetMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.RequiredArgsConstructor;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/tv")
@RequiredArgsConstructor
@Component
public class TvInfoController {
    private final TvInfoService tvInfoService;
    @CrossOrigin(origins ="*" ,maxAge = 3600)
    @GetMapping("/select")
    public GetMessage select () throws JsonProcessingException, MqttException {
        List<TvInfo> list=tvInfoService.selcet();

        return new GetMessage("成功","200",list);

    }
}
